<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\Foundation\Auth\AuthenticatesUsers;

class LoginController extends Controller
{
    use AuthenticatesUsers;

    public function __construct()
    {
        $this->middleware('guest:admin');
    }

    protected $redirectTo = '/admin/home';

    public function index()
    {
        return view('admin.login.sign-in');
    }



    public function login(Request $request)
    {
        if (!auth()->guard('admin')->attempt(['email'=>$request->email,'password'=>$request->password], $request->rememberme)) {
            $request->session()->flash('errors', 'Error');
            return back();
        }
        return redirect()->intended(route('admin.home'));
    }

    protected function guard()
    {
        return Auth::guard('admin');
    }
}
